import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI)

Vue.config.productionTip = false
router.beforeEach((to, from, next) => {
    let token = window.localStorage.getItem('token')
    if (to.matched.some(record => record.meta.requiresAuth) && (!token)) {
        next({
            path: '/login'
        })
    } else {
        next()
    }
})


new Vue({
    router,
    render: h => h(App),
}).$mount('#app')
